// 权限

const fs= require("fs");
const path=require("path");

let filePath=path.join(__dirname,"test.txt");
let toPath=path.join(__dirname,"to.txt");

let readStream=fs.createReadStream(filePath);

let writeStream=fs.createWriteStream(toPath);

readStream.pipe(writeStream)

//获取文件的信息stat
let fileObj=fs.statSync(filePath)
//把filePath的权限赋给toPath
fs.chmodSync(toPath,fileObj.mode)